	var IfStatusData = [{
		id:'',
		name:'全部',
		'selected':'true'
	},{
		id:'0',
		name:'停用'
	},{
		id:'1',
		name:'启用'
	}];
	
	var IfAuditStatusData = [{
		id:'',
		name:'全部',
		'selected':'true'
	},{
		id:'0',
		name:'未审核'
	},{
		id:'1',
		name:'已审核'
	}];
	
	
	var requestMethod = [{
		id:'0',
		name:'GET'
	},{
		id:'4',
		name:'POST'
	}];

	var isModify = true;
	//定位显示
	var arrayLi = [];
	var arrayLiInd = 0;
	
	var deleteParamIds ="";
	var httpBundleId = "";
	
	var authModeTotal = [{
		valueName:"免认证",
		valueCode:"0"
	},{
		valueName:"Http-Basic-Key",
		valueCode:"1"
	},{
		valueName:"Oauth认证",
		valueCode:"2"
	},{
		valueName:"WS-Security",
		valueCode:"3"
	}];
	
	
	$(document).ready(function(){
		var urlParamObj = getParamobjFromUrl();
		var name = urlParamObj.name;
		var fieldName = urlParamObj.fieldName;
		var systemName = urlParamObj.systemName;
		
		/* 系统树 */
		$('#system_selection').window({
			width:310,
			height:355,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false,
			onClose: function () {
				$("#tt").html("");
			}
		});
		$('#system_selection').window('close');  //关闭窗口
		
		$('#win').window('close');
		
		//alert("sldflsd");
		$('#comboxSearchField').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName.combobox({
                    disabled: false,
                    method:'get',
                    queryParams: {fieldId: record.id},
                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
                    valueField: 'id',
                    textField: 'name',
					data:'',
        		    loadFilter: function(data){
        		    	var allCheck = {'id':'','name':'全部'};
        		    	data.content.unshift(allCheck);
        		    	return data.content;
        		    },
        		    onLoadSuccess:function(){
        		    	comboxSearchSystemName.combobox('setValue','');
        				if(systemName){
        					var datas = $('#comboxSearchFieldSystem').combobox('getData');
        					for(var j = 0; j < datas.length; j++){
        						if(datas[j].name == window.decodeURI(systemName)){
        							$('#comboxSearchFieldSystem').combobox('select',datas[j].id);
        							$("#datagrid").datagrid("reload");
        						}
        					}
        					//$('#comboxSearchFieldSystem').combobox('select',window.decodeURI(systemName));
        				}
        		    }
                }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchField').combobox('setValue','');
		    	if(fieldName){
		    		var data = $('#comboxSearchField').combobox('getData');
					for(var i = 0; i < data.length; i++){
						if(data[i].name == window.decodeURI(fieldName)){
							$('#comboxSearchField').combobox('select',data[i].id);
						}
					}
					//$('#comboxSearchField').combobox('select',window.decodeURI(fieldName));
				}
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchFieldSystem').combobox({
            disabled: true,
            valueField: 'id',
            textField: 'name',
            editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
        });
		
		var comboxInterfaceStatus = $('#comboxInterfaceStatus').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfStatusData
        });
		
		
		var comboxAuditStatus = $('#comboxAuditStatus').combobox({
            valueField: 'id',
            textField: 'name',
            editable: false,
		  	data:IfAuditStatusData
        });
		
		
		if(name){
			$('#interfaceName').val(window.decodeURI(name));
		}
		
		
		$("#datagrid").datagrid({
			url : BASE_URL_HTTP_INTERFACE_SEARCH + '/findInterfacesByUser?v='+Math.random(),
			method:'get',
			autoRowHeight:true,
			singleSelect:false,
			striped:true,
			nowrap:false,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'',width:10,checkbox:true},
						{field:'fieldName',title:'领域',width:80},
						{field:'systemName',title:'系统',width:70},
						{field:'interfaceType',title:'接口类型',width:120},
						{field:'interfaceName',title:'接口名称',width:115},
						{field:'interfaceCode',title:'接口编码',width:115},
						{field:'createdDate',title:'注册时间',width:150},
						{field:'auditStatus',title:'审核状态',width:60},
						{field:'interfaceVersion',title:'版本',width:70},
						{field:'bundleName',title:'bundle编号',width:120},
						{field:'interfaceStatus',title:'操作',width:60,
							formatter: function(value,row,index){
								if(value == 0){
									if(row.auditStatus == "已审核"){
										return '<a href="#" class="default_btn default_open" onclick="changeIfStatus(\'' + index+ '\')"></a>';
									}else{
										return '<a href="#" class="default_btn default_open"></a>';
									}
								}else if(value == 1){
									if(row.auditStatus == "已审核"){
										return '<a href="#" class="default_btn default_close" onclick="changeIfStatus(\'' + index+ '\')"></a>';
									}else{
										return '<a href="#" class="default_btn default_close"></a>';
									}
									
								}else{
									return "";
								}
							}
						}
			      ]],
			pagination:true,
			loadFilter:function(data){
				//alert("inData:"+JSON.stringify(data));
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onSelect:function(rowIndex, rowData){
				if(rowData.interfaceType=='FTP'){
					$('#toolbar_upgrade').linkbutton('disable');
				}else{
					$("#toolbar_upgrade").linkbutton('enable');
				}
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				param.sort = 'createTime,desc';
				var fieldId = $('#comboxSearchField').combobox('getValue');
				if(fieldId){
					param.fieldId = fieldId;
				}else{
					param.fieldId = "";
				}
				
				var fieldSystemId = $('#comboxSearchFieldSystem').combobox('getValue');
				if(fieldSystemId){
					param.fieldSystemId = fieldSystemId;
				}else{
					param.fieldSystemId = "";
				}
				var Status = $('#comboxInterfaceStatus').combobox('getValue');
				if(Status){
					param.Status = Status;
				}else{
					param.Status = "";
				}
				
				var auditStatus = $('#comboxAuditStatus').combobox('getValue');
				if(auditStatus !=""){
					param.auditStatus = auditStatus;
				}else{
					param.auditStatus = "";
				}
				 
				var name = $('#interfaceName').val();
				if(name !=""){
					param.name = name;
				}else{
					param.name = "";
				}
				
				var code = $('#serachInterfaceCode').val();
				if(code !=""){
					param.code = code;
				}else{
					param.code = "";
				}
				
				param["createTime"] = $("#txtCreateTimeBeg").datetimebox('getValue');
				param["endTime"] = $("#txtCreateTimeEnd").datetimebox('getValue');
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 
		
		$(".button_con a" ).removeClass("l-btn-plain");
		
		
		//初始化http修改页面
		$('#wizard').smartWizard({
	  		  // Properties
	  		    selected: 0,  // Selected Step, 0 = first step   
	  		    keyNavigation: false, // Enable/Disable key navigation(left and right keys are used if enabled)
	  		    enableAllSteps: true,  // Enable/Disable all steps on first load
	  		    transitionEffect: 'fade', // Effect on navigation, none/fade/slide/slideleft
	  		    contentURL:null, // specifying content url enables ajax content loading
	  		    contentCache:true, // cache step contents, if false content is fetched always from ajax url
	  		    cycleSteps: false, // cycle step navigation
	  		    enableFinishButton: false, // makes finish button enabled always
	  		    errorSteps:[],    // array of step numbers to highlighting as error steps
	  		    labelNext:'下一步', // label for Next button
	  		    labelPrevious:'上一步', // label for Previous button
	  		    labelFinish:'提交',  // label for Finish button        
	  		  // Events
	  		    onLeaveStep: onLeaveStepCallBack, // triggers when leaving a step
	  		    onShowStep: onShowStepCallBack,  // triggers when showing a step
	  		    onFinish: onFinishCallBack  // triggers when Finish button is clicked
	  		 });
		
	  		
	  		$('#comboxFieldName').combobox({
				url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
				valueField: 'id',
			    textField: 'name',
			    editable:false,
			    method:'get',
			    loadFilter: function(data){
			    	return data.content;
			    },
			    onLoadSuccess:function(){
			    	/*var FieldName = $('#comboxFieldName').combobox('getData');
			    	$("#comboxFieldName").combobox('setValue',FieldName[0].id);*/
			    },	
			    onSelect: function(record){
			    	comboxSystemName.combobox({
	                    disabled: false,
	                    method:'get',
	                    queryParams: {fieldId: record.id},
	                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
	                    valueField: 'id',
	                    textField: 'name',
	        		    loadFilter: function(data){
	        		    	return data.content;
	        		    }
	                }).load();
			    },
			    onChange: function(newValue,oldValue){
			    	comboxSystemName.combobox({
	                    disabled: false,
	                    method:'get',
	                    queryParams: {fieldId: newValue},
	                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
	                    valueField: 'id',
	                    textField: 'name',
	        		    loadFilter: function(data){
	        		    	return data.content;
	        		    },
	        		    onLoadSuccess : function(){
	        		    	/*var SystemName = $('#comboxSystemName').combobox('getData');
	        				$("#comboxSystemName").combobox('setValue',SystemName[0].id);*/
	        		    }
	                }).load();
			    }
			    
			});
			
			
			var comboxSystemName = $('#comboxSystemName').combobox({
	            disabled: true,
	            valueField: 'id',
	            textField: 'name',
	            editable:false
	        });
			
			$('#comboxInterfaceDataFormat').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_INTERFACE_DATA_FORMAT + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var interfaceDataFormat = $('#comboxInterfaceDataFormat').combobox('getData');
			    	$("#comboxInterfaceDataFormat").combobox('setValue',interfaceDataFormat[0].valueCode);
			    }
			});
			
			var comboxInterfaceReqeustMethod = $('#comboxInterfaceReqeustMethod').combobox({
	            valueField: 'id',
	            textField: 'name',
	            editable: false,
			  	data:requestMethod,
			  	onLoadSuccess:function(){
			    	$("#comboxInterfaceReqeustMethod").combobox('setValue',"0");
			    }
	        });
			
			
			$('#comboxReqParameterType').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_PARAMETER_TYPE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var reqParameterType = $('#comboxReqParameterType').combobox('getData');
			    	$("#comboxReqParameterType").combobox('setValue',reqParameterType[0].valueCode);
			    }
			});
			
			
			$('#reviseComboxReqParameterType').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_PARAMETER_TYPE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var reqParameterType = $('#reviseComboxReqParameterType').combobox('getData');
			    	$("#reviseComboxReqParameterType").combobox('setValue',reqParameterType[0].valueCode);
			    }
			});
			
			$('#reviseComboxRepParameterType').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_PARAMETER_TYPE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var reqParameterType = $('#reviseComboxRepParameterType').combobox('getData');
			    	$("#reviseComboxRepParameterType").combobox('setValue',reqParameterType[0].valueCode);
			    }
			});
			
			$('#comboxRepParameterType').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_PARAMETER_TYPE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var repParameterType = $('#comboxRepParameterType').combobox('getData');
			    	$("#comboxRepParameterType").combobox('setValue',repParameterType[0].valueCode);
			    }
			});
			
			
			
			
			$('#comboxIsPublic').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_IS_PUBLIC + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var isPublic = $('#comboxIsPublic').combobox('getData');
			    	$("#comboxIsPublic").combobox('setValue',isPublic[0].valueCode);
			    	
			    	var chooseVal = $("#comboxIsPublic").combobox('getValue');
			    	if(chooseVal=="0"){
			    		$("#li_visible").css("display","block");
			    	}else{
			    		$("#li_visible").css("display","none");
			    	}
			    	
			    },
			    onSelect: function(record){
			    	var chooseVal = $("#comboxIsPublic").combobox('getValue');
			    	if(chooseVal=="0"){
			    		$("#li_visible").css("display","block");
			    	}else{
			    		$("#li_visible").css("display","none");
			    	}
			    }
			});
			
			
			$('#comboxOperationType').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_OPERATION_TYPE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var operationType = $('#comboxOperationType').combobox('getData');
			    	$("#comboxOperationType").combobox('setValue',operationType[0].valueCode);
			    }
			});
			
			
			$('#comboxAuthencationMode').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_AUTHENTICATION_MODE + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var authencationMode = $('#comboxAuthencationMode').combobox('getData');
			    	$("#comboxAuthencationMode").combobox('setValue',authencationMode[0].valueCode);
			    }
			});
			
			$('#comboxSoapProtocol').combobox({
				url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode='+DDTC_SOAP_PROTOCOL + '&v=' + Math.random(),
				valueField: 'valueCode',
			    textField: 'valueName',
			    editable:false,
			    method:'get',
			    loadFilter:function(data){
			    	return data;
			    },
			    onLoadSuccess:function(){
			    	var soapProtocol = $('#comboxSoapProtocol').combobox('getData');
			    	$("#comboxSoapProtocol").combobox('setValue',soapProtocol[0].valueCode);
			    }
			});
			  
		  	function onLeaveStepCallBack(obj, context){
		  		var row = $('#datagrid').datagrid('getSelected');
		  		var step_num= obj.attr('rel'); // get the current step number
		  		/*验证表单数据是否正确*/
		  		if(context.fromStep < context.toStep){
			  		if(step_num == 1){
			  			if(!$("#basicInfoForm").form("validate")){
			  				return false;
			  			}
			  			if(row.type == '1'){
			  				//webservice
			  				
			  			}else if(row.type == '2'){
			  				//rest
			  				
			  			}
			  			if(row.bundleType == '0'){
			  				//代理模式
			  				var interfaceOriginAddress = $("#interfaceOriginAddress").val();
			  				if(interfaceOriginAddress != "")
							{
							}else
							{
								$.messager.alert('警告', '<p>接口原始地址不能为空!</p>', 'warning');
								return false;
							}
			  			}else if(row.bundleType == '1'){
			  				//自定义模式
			  				var packageJarName = $("#packageJarName").val();
			  				if(packageJarName != "")
							{
							}else
							{
								$.messager.alert('警告', '<p>接口部署包不能为空!</p>', 'warning');
								return false;
							}
			  			}
			  		}else if(step_num == 2){
			  			if(row.type == '1'){
			  				//webservice
			  				var requestParametersMsg = $("#requestParametersMsg").val();
			  				if(requestParametersMsg != "")
							{
							}else
							{
								$.messager.alert('警告', '<p>接口请求报文不能为空!</p>', 'warning');
								return false;
							}
			  			}else if(row.type == '2'){
			  				//rest
			  				
			  			}
			  		}else if(step_num == 3){
			  			
			  		}else if(step_num == 4){
			  			if(!$("#limitForm").form("validate")){
			  				return false;
			  			}
			  		}else{
			  			
			  		}
		  		}
		  		/*保存表单数据*/
		  		return true;
		  		
		  	}
		  	
		  	function onShowStepCallBack(obj){
		  		var step_num= obj.attr('rel');
		  		if(step_num == 1){
		  			//alert("onShowStepCallBack" + step_num);
		  		}else if(step_num == 2){
		  			//alert("onShowStepCallBack" + step_num);
		  		}else if(step_num == 3){
		  			//alert("onShowStepCallBack" + step_num);
		  		}else{
		  			//alert("onShowStepCallBack" + step_num);
		  		}
		  		
		  	}
		  	
		  	function onFinishCallBack(){
		  		var result = getFormDatas();
		  		if(result == false){
		  			return;
		  		}
		  		var interfaceDatas = getFormDatas();
		  		//alert(interfaceDatas);
		  		var jsonData = {
					  	interfaceDatas:interfaceDatas
					};
		  	
		  		//alert(JSON.stringify(jsonData));
		  		if($("#basicInfoForm").form("validate") && $("#limitForm").form("validate")){
		  			$("#progressbar2, #progressbar_tips2").fadeIn();
		  			loading_point.timer = setInterval(loading2,200);
			  		if(isModify){
			  			//接口修改
				  		$.ajax({
				  			type: "post",
				  			url: BASE_URL_HTTP_INTERFACE + '/httpServiceUpdate' + '?v=' + Math.random(),
				  			dataType:'json',
				  			data: JSON.stringify(jsonData),
				  			contentType:"application/json",
				  			success: function(result) {
				  				$("#progressbar2, #progressbar_tips2").fadeOut();
			  					clearInterval(loading_point.timer);
				  				//alert("result" + result.backValue);
				  				if(result.backValue == true){
				  					$.messager.alert('提示','<p>修改成功！</p>','info',function(){
				  						$('#win').window('close');
				  						$("#datagrid").datagrid("reload");
				  					});
				  				}else if(result.backValue == false){
				  					$.messager.alert('错误','<p>' + result.errorDes + '</p>','error');
				  				}else{
				  					
				  				}
				  			},
				  			error: function() {
				  				$("#progressbar2, #progressbar_tips2").fadeOut();
								clearInterval(loading_point.timer);
				  				$.messager.alert('错误','<p>服务异常，修改失败，请稍后重试或联系管理员!</p>', 'error');
				  			}
				  		});
			  		}else{
			  			//接口版本升级
			  			$.ajax({
				  			type: "post",
				  			url: BASE_URL_HTTP_INTERFACE + '/httpServiceUpVersion' + '?v=' + Math.random(),
				  			dataType:'json',
				  			data: JSON.stringify(jsonData),
				  			contentType:"application/json",
				  			success: function(result) {
				  				$("#progressbar2, #progressbar_tips2").fadeOut();
								clearInterval(loading_point.timer);
				  				//alert(result.backValue);
				  				//alert("result" + result.backValue);
				  				if(result.backValue == true){
				  					$.messager.alert('提示','<p>版本升级成功</p>','info',function(){
				  						$('#win').window('close');
				  						$("#datagrid").datagrid("reload");
				  					});
				  				}else if(result.backValue == false){
				  					$.messager.alert('错误','<p>' + result.errorDes + '</p>','error');
				  				}else{
				  					
				  				}
				  			},
				  			error: function() {
				  				$("#progressbar2, #progressbar_tips2").fadeOut();
								clearInterval(loading_point.timer);
				  				$.messager.alert('错误','<p>服务异常，版本升级失败，请稍后重试或联系管理员!</p>', 'error');
				  			}
				  		});
			  		}
		  		}
		  		
		  	}
			
		  	
		    //动态添加接口请求参数数据项
			$(".confirm_title").click(function(e) {
				if($("#requestParametersForm").form("validate")){
					var reqParamId = $("#reqParamId").val();
		            var reqParameterName = $("#reqParameterName").val();
					var reqParameterType = $("#comboxReqParameterType").combobox('getValue');
					var reqParameterTypeDispaly = $("#comboxReqParameterType").combobox('getText');
					var reqParameterIsMust = $("#reqParameterIsMust").is(":checked");
					var reqParameterIsMustValue;
					//alert($("#reqParameterIsMust").is(":checked"));
					
					var reqParameterIsMustDispaly;
					if(reqParameterIsMust == true){
						reqParameterIsMustValue = "1";
						reqParameterIsMustDispaly = "是";
					}else{
						reqParameterIsMustValue = "0";
						reqParameterIsMustDispaly = "否";
					}
					var reqParameterDefaultValue = $("#reqParameterDefaultValue").val();
					var reqParameterDes = $("#reqParameterDes").val();
					if(reqParameterName != '' && reqParameterType !== '')
					{
						var tableHtml = '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" style="display:none" class="reqParamId">' + reqParamId + '</td><td width="16.7%" class="reqParameterName"><p class="txtP" title="' + reqParameterName + '">' + reqParameterName + '</p></td><td width="16.7%" class="comboxReqParameterType" data-val="' + reqParameterType + '"><p class="txtP" title="' + reqParameterTypeDispaly + '">' + reqParameterTypeDispaly + '</p></td><td width="16.7%" class="reqParameterIsMust" data-val="' + reqParameterIsMustValue + '"><p class="txtP" title="' + reqParameterIsMustDispaly + '">' + reqParameterIsMustDispaly + '</p></td><td width="16.7%" class="reqParameterDefaultValue"><p class="txtP" title="' + reqParameterDefaultValue + '">' + reqParameterDefaultValue + '</p></td><td width="16.7%" class="reqParameterDes"><p class="txtP" title="' + reqParameterDes + '">' + reqParameterDes + '</p></td><td width="16.7%" class="operation_table"><a href="javascript:void(0);" class="change_title">更改</a><a href="javascript:void(0);" class="del_title">删除</a></td></tr>';
						$(".add").find("tr").eq(0).after(tableHtml);
						$("#reqParamId, #reqParameterName, #comboxReqParameterType, #reqParameterIsMust, #reqParameterDefaultValue, #reqParameterDes").val('');
					}else
					{
						$.messager.alert('警告', '<p>请填写完整！</p>', 'warning');
					}
				}
				else
				{
					$(".interfaceDataAdd .validatebox-invalid").eq(0).focus();
				}
	        });
		  
		  
			//修改接口请求参数数据项
			$('#interface_change').window({
				width:650,
				height:140,
				modal:true,
				minimizable:false,
				maximizable:false,
				collapsible:false
			});
			$('#interface_change').window('close');  //关闭窗口
			var rev_index;
			$("body").delegate(".change_title","click",function(e) {
				$("#reviseParamId, #reviseReqParameterName, #reviseComboxReqParameterType, #reviseReqParameterIsMust, #reviseReqParameterDefaultValue, #reviseReqParameterDes").val("");
				rev_index = $(this).parents("tr").attr("id");
				var reqParamId = $(this).parents("td").siblings(".reqParamId").text();
				var reqParameterName = $(this).parents("td").siblings(".reqParameterName").text();
				var reqParameterType = $(this).parents("td").siblings(".comboxReqParameterType").attr("data-val");
				var reqParameterDes = $(this).parents("td").siblings(".reqParameterDes").text();
				var reqParameterDefaultValue = $(this).parents("td").siblings(".reqParameterDefaultValue").text();
				var reqParameterIsMust = $(this).parents("td").siblings(".reqParameterIsMust").attr("data-val");
				var html;
				
				$("#reviseParamId").val(reqParamId);
				$("#reviseReqParameterName").val(reqParameterName);
				$("#reviseComboxReqParameterType").combobox('select',reqParameterType);
				if(reqParameterIsMust == "1"){
					$("#reviseReqParameterIsMust")[0].checked = true;
				}else{
					$("#reviseReqParameterIsMust")[0].checked = false;
				}
				$("#reviseReqParameterDefaultValue").val(reqParameterDefaultValue);
				$("#reviseReqParameterDes").val(reqParameterDes);
				$('#interface_change').window('open');	
				return false;
			});
			
			$("body").delegate(".confirm_title_revise","click",function(e) {
				if($("#requestReviseParam").form("validate")){
					$("#" + rev_index).children(".reqParamId").text($("#reviseParamId").val());
					$("#" + rev_index).children(".reqParameterName").html('<p class="txtP" title="' + $("#reviseReqParameterName").val() + '">' + $("#reviseReqParameterName").val() + '</p>');
					$("#" + rev_index).children(".comboxReqParameterType").attr("data-val",$("#reviseComboxReqParameterType").combobox('getValue'));
					$("#" + rev_index).children(".comboxReqParameterType").html('<p class="txtP" title="' + $("#reviseComboxReqParameterType").combobox('getText') + '">' + $("#reviseComboxReqParameterType").combobox('getText') + '</p>');
					var reviseReqParameterIsMust = $("#reviseReqParameterIsMust").is(":checked");
					var reviseReqParameterIsMustValue;
					if(reviseReqParameterIsMust == true){
						reviseReqParameterIsMustValue = "1";
						reviseReqParameterIsMustDispaly = "是";
					}else{
						reviseReqParameterIsMustValue = "0";
						reviseReqParameterIsMustDispaly = "否";
					}
					
					$("#" + rev_index).children(".reqParameterIsMust").attr("data-val",reviseReqParameterIsMustValue);
					$("#" + rev_index).children(".reqParameterIsMust").html('<p class="txtP" title="' + reviseReqParameterIsMustDispaly + '">' + reviseReqParameterIsMustDispaly + '</p>');
					$("#" + rev_index).children(".reqParameterDefaultValue").html('<p class="txtP" title="' + $("#reviseReqParameterDefaultValue").val() + '">' + $("#reviseReqParameterDefaultValue").val() + '</p>');
					$("#" + rev_index).children(".reqParameterDes").html('<p class="txtP" title="' + $("#reviseReqParameterDes").val() + '">' + $("#reviseReqParameterDes").val() + '</p>');
					$('#interface_change').window('close');	
				}else{
					$(".interfaceDataAdd .validatebox-invalid").eq(0).focus();
				}
			});
			
			//删除接口数据项
			$("body").delegate(".del_title","click",function(){
				$(this).parents("tr").remove();
				var paramId = $(this).parents("tr").children("td").eq(0).text();
				deleteParamIds += (deleteParamIds == ""? "":",") + paramId;
			});
			
			
			
			 //动态添加接口返回参数数据项
			$(".confirm_title_rep").click(function(e) {
				if($("#responseParametersForm").form("validate")){
					var repParamId = $("#repParamId").val();
		            var repParameterName = $("#repParameterName").val();
					var repParameterType = $("#comboxRepParameterType").combobox('getValue');
					var repParameterTypeDispaly = $("#comboxRepParameterType").combobox('getText');
					var repParameterDes = $("#repParameterDes").val();
					if(repParameterName != '' && repParameterType !== '')
					{
						var tableHtml = '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" style="display:none" class="repParamId">' + repParamId + '</td><td width="25%" class="repParameterName"><p class="txtPP" title="' + repParameterName + '">' + repParameterName + '</p></td><td width="25%" class="comboxRepParameterType" data-val="' + repParameterType + '"><p class="txtPP" title="' + repParameterTypeDispaly + '">' + repParameterTypeDispaly + '</p></td><td width="25%" class="repParameterDes"><p class="txtPP" title="' + repParameterDes + '">' + repParameterDes + '</p></td><td width="25%" class="operation_table"><a href="javascript:void(0);" class="change_title_rep">更改</a><a style="margin-left:10px;" href="javascript:void(0);" class="del_title_rep">删除</a></td></tr>';
						$(".add_rep").find("tr").eq(0).after(tableHtml);
						$("#repParamId, #repParameterName, #comboxRepParameterType, #repParameterDes").val('');
					}else
					{
						$.messager.alert('警告', '<p>请填写完整！</p>', 'warning');
					}
				}
				else
				{
					$(".interfaceDataAdd_rep .validatebox-invalid").eq(0).focus();
				}
		    });
			
			
			//修改接口返回参数数据项
			$('#interface_change_rep').window({
				width:555,
				height:140,
				modal:true,
				minimizable:false,
				maximizable:false,
				collapsible:false
			});
			$('#interface_change_rep').window('close');  //关闭窗口
			var rev_index;
			$("body").delegate(".change_title_rep","click",function(e) {
				$("#reviseRepParamId, #reviseRepParameterName, #reviseComboxRepParameterType, #reviseRepParameterDes").val("");
				rev_index = $(this).parents("tr").attr("id");
				var repParamId = $(this).parents("td").siblings(".repParamId").text();
				var repParameterName = $(this).parents("td").siblings(".repParameterName").text();
				var repParameterType = $(this).parents("td").siblings(".comboxRepParameterType").attr("data-val");
				var repParameterDes = $(this).parents("td").siblings(".repParameterDes").text();
				var html;
				
				$("#reviseRepParamId").val(repParamId);
				$("#reviseRepParameterName").val(repParameterName);
				$("#reviseComboxRepParameterType").combobox('select',repParameterType);
				$("#reviseRepParameterDes").val(repParameterDes);
				$('#interface_change_rep').window('open');	
				return false;
			});
			
			$("body").delegate(".confirm_title_revise_rep","click",function(e) {
				if($("#reponseReviseParam").form("validate")){
					$("#" + rev_index).children(".repParamId").text($("#reviseRepParamId").val());
					$("#" + rev_index).children(".repParameterName").html('<p class="txtPP" title="' + $("#reviseRepParameterName").val() + '">' + $("#reviseRepParameterName").val() + '</p>');
					$("#" + rev_index).children(".comboxRepParameterType").attr("data-val",$("#reviseComboxRepParameterType").combobox('getValue'));
					$("#" + rev_index).children(".comboxRepParameterType").html('<p class="txtPP" title="' + $("#reviseComboxRepParameterType").combobox('getText') + '">' + $("#reviseComboxRepParameterType").combobox('getText') + '</p>');
					$("#" + rev_index).children(".repParameterDes").html('<p class="txtPP" title="' + $("#reviseRepParameterDes").val() + '">' + $("#reviseRepParameterDes").val() + '</p>');
					$('#interface_change_rep').window('close');	
				}else{
					$(".interfaceDataAdd .validatebox-invalid").eq(0).focus();
				}
			});
			
			
			//删除接口返回数据项
			$("body").delegate(".del_title_rep","click",function(){
				$(this).parents("tr").remove();
				var paramId = $(this).parents("tr").children("td").eq(0).text();
				deleteParamIds += (deleteParamIds == ""? "":",") + paramId;
			});
			
			
			$("#selSystemBtn").click(function(e) {
				//if(treeData==null){
					$("#tt").tree({
						url:BASE_URL_TREE + '/getFieldSystemsForEasyUiTree' + '?v=' + Math.random(),
						method: "get",
						lines:false,
						async:false,
						checkbox: true,
						loadFilter: function(data,parent) {
							treeData = [{text:"全部", children:data, nodeType:"root"}];
							return treeData;
						},
						onLoadSuccess:function()
						{
							$("#tt > li > ul > li > ul > li > .tree-node > .tree-file").css("background","url('../../../images/st_folder.png') no-repeat 2px 2px");
							$("#tt > li > ul > li > .tree-node > .tree-file").parent().parent().css("display","none");
							reSetTree();
						},
						onClick:function(node){
							if(node.checked)
							{
								$("#tt").tree("uncheck", node.target);
							}
							else
							{
								$("#tt").tree("check", node.target);
							}
							
							//$("#systemName").val(node.text);
							//choose_tree();
						}
					});
				//}else{
					//reSetTree()
				//}
				
				
				return false;
			});
			
			$("#ensureSelect").click(function (e) {
				var checkedNodes = $("#tt").tree("getChecked");
				var selectSystems = "";
				var systemsName = "";
				for(var i = 0, len = checkedNodes.length; i < len; ++i)
				{
					var tempNode = checkedNodes[i];
					if(tempNode.nodeType != "fieldSystem")
					{
						continue;
					}
					selectSystems += (selectSystems != ""? ",":"") + tempNode.id;
					systemsName += (systemsName != ""? ",":"") + tempNode.text;
				}
				$("#strFieldSystems").val(selectSystems);
				$("#system").val(systemsName);
				$('#system_selection').window('close');	
			});
			
			
			$("#searchNode").click(function (e) { 
				if($("#systemName").val() != '')
				{
					choose_tree();
				}
				else
				{
					$("#systemName").val("");//将。改为#
					var row = $('#tt li .tree-node');  
					row.removeClass('tree-node-selected');
					$(".tree_con").scrollTop(0);
				}
			});
			
			$("#systemName").bind('input propertychange', function() {
				arrayLi = [];
				arrayLiInd = 0;
				if($("#systemName").val() != '')
				{
					choose_tree();
				}else
				{
					$("#ff input").val("");
					var row = $('#tt li .tree-node');  
					row.removeClass('tree-node-selected');
					$(".tree_con").scrollTop(0);
				}
			});
			
			$(document , "#systemName").keyup(function(event){
			  if(event.keyCode == 8){
			    $("#searchNode").trigger("click");
			  }
			});
			$(document , "#systemName").keyup(function(event){
			  if(event.keyCode ==13){
			    $("#searchNode").trigger("click");
			  }
			});
	
	});
	
	
	function changeIfStatus(index){
		var row = $('#datagrid').datagrid('getRows')[parseInt(index, 10)];
		var status = row.interfaceStatus;
		//alert(JSON.stringify(row));
		var jsonData = {
				id:row.interfaceId,
				interfaceType:row.type
		}
		$("#progressbar1, #progressbar_tips1").fadeIn();
		loading_point.timer = setInterval(loading1,200);
		$.ajax({
  			type: "get",
  			url: BASE_URL_HTTP_INTERFACE + '/updateInterfaceStatus' + '?v=' + Math.random(),
  			dataType:'json',
  			data: jsonData,
  			contentType:"application/json",
  			success: function(result) {
  				$("#progressbar1, #progressbar_tips1").fadeOut();
				clearInterval(loading_point.timer);
  				//alert("result" + result.backValue);
  				if(result.backValue == true){
  					if(status == '0'){
	  					$.messager.alert('提示','<p>启用成功</p>','info',function(){
	  						$('#datagrid').datagrid('reload');
	  					});
  					}
  					
  					if(status == '1'){
	  					$.messager.alert('提示','<p>停用成功</p>','info',function(){
	  						$('#datagrid').datagrid('reload');
	  					});
  					}
  					
  				}else if(result.backValue == false){
  					$.messager.alert('错误','<p>' + result.errorDes + '</p>','error',function(){
  						$('#datagrid').datagrid('reload');
  					});
  				}
  				else{
  				}
  			},
  			error: function() {
  				$("#progressbar1, #progressbar_tips1").fadeOut();
				clearInterval(loading_point.timer);
  				$.messager.alert('错误','<p>服务异常，更改接口状态失败，请稍后重试或联系管理员!</p>', 'error');
  			}
  		});
	}
	
	
	//注册
	function onRegister(){
		window.parent.OpenTab("服务注册","pages/esb/ServiceManagement/serviceRegistration.html","", true);
	}
	
	//更新
	function onUpdate(){
		isModify = true;
		var row = $('#datagrid').datagrid('getSelections');
		if(row.length == 0){
 			$.messager.alert('警告',"<p>请选中要修改的记录!</p>","warning");
 			return ;
 		}
		if(row.length > 1){
 			$.messager.alert('警告',"<p>您选中要修改的记录超过了一条!</p>","warning");
 			return ;
 		}
		
		//alert(row.type);
		if(row[0].type == '1' || row[0].type == '2'){
			httpUpdate(row[0]);
		}else if(row[0].type == '3'){
			FtpUpdate(row[0]);
		}
		
	}
	
	//版本升级
	function onVersionUpgrade(){
		isModify = false;
		var row = $('#datagrid').datagrid('getSelections');
		if(row.length == 0){
 			$.messager.alert('警告',"<p>请选中要进行版本升级的记录!</p>","warning");
 			return ;
 		}
		if(row.length > 1){
 			$.messager.alert('警告',"<p>您选中要进行版本升级的记录超过了一条!</p>","warning");
 			return ;
 		}
		var jsonData = {
			interfaceCode:row[0].interfaceCode
		}
		var maxVersion = "";
		$.ajax({
  			type: "get",
  			url: BASE_URL_HTTP_INTERFACE + '/findIfMaxVersionById' + '?v=' + Math.random(),
  			dataType:'json',
  			data: jsonData,
  			contentType:"application/json",
  			success: function(result) {
  				maxVersion = result.maxVersion;
  				var newVersion = "v" + upVersion(maxVersion) + ".0";
  				$.messager.confirm('温馨提示','<p>当前接口的最高版本为' + maxVersion + '，您是否要另存为' + newVersion + '的新版本?</p>',function(result){
  					if(result){
  						//alert(row.type);
  						if(row[0].type == '1' || row[0].type == '2'){
  							httpVersionUpgrade(row[0], maxVersion);
  						}else if(row[0].type == '3'){
  							//FtpVersionUpgrade(row);
  						}
  					}
  				});
  			},
  			error: function(){
  				$.messager.alert('错误','<p>服务异常，请稍后重试或联系管理员!</p>', 'error');
  			}
		});
		
		
		
		
	}
	
	
	//卸载
	function onUnload(){
		var row = $('#datagrid').datagrid('getSelections');
		if(row.length == 0){
 			$.messager.alert('警告',"<p>请选中要卸载的记录!</p>","warning");
 			return ;
 		}
		if(row.length > 1){
 			$.messager.alert('警告',"<p>您选中要卸载的记录超过了一条!</p>","warning");
 			return ;
 		}
		
		$.messager.confirm('温馨提示','<p>您真的要卸载么?</p>',function(result){
			if(result){
				var jsonData = {
						id:row[0].interfaceId
					}
				
				$("#progressbar1, #progressbar_tips1").fadeIn();
				loading_point.timer = setInterval(loading1,200);
				$.ajax({
		  			type: "get",
		  			url: BASE_URL_HTTP_INTERFACE + '/interfaceUninstall' + '?v=' + Math.random(),
		  			dataType:'json',
		  			data: jsonData,
		  			contentType:"application/json",
		  			success: function(result) {
		  				$("#progressbar1, #progressbar_tips1").fadeOut();
						clearInterval(loading_point.timer);
		  				if(result.backValue == true){
		  					$.messager.alert('提示','<p>卸载成功!</p>','info',function(){
		  						$('#datagrid').datagrid('reload');
		  					});
		  				}else if(result.backValue == false){
		  					$.messager.alert('错误','<p>' + result.errorDes + '</p>','error',function(){
		  						$('#datagrid').datagrid('reload');
		  					});
		  				}
		  				
		  			},
		  			error: function(){
		  				$("#progressbar1, #progressbar_tips1").fadeOut();
						clearInterval(loading_point.timer);
		  				$.messager.alert('错误','<p>服务异常，卸载失败，请稍后重试或联系管理员!</p>', 'error');
		  			}
				});	
			}
		});
	}
	
	function httpUpdate(row){
		var reqRows = $(".add").find("tr").size();
		for(var i = reqRows; i >　1; i--){
			$(".add").find("tr").eq(i - 1).remove();
		}
		
		var repRows = $(".add_rep").find("tr").size();
		for(var j = repRows; j >　1; j--){
			$(".add_rep").find("tr").eq(j - 1).remove();
		}
		deleteParamIds = "";
		var jsonData = {
				id:row.interfaceId
			}
			/* 根据接口id获取接口信息进行表单回显  */
			$.ajax({
	  			type: "get",
	  			url: BASE_URL_HTTP_INTERFACE + '/findIfById' + '?v=' + Math.random(),
	  			dataType:'json',
	  			data: jsonData,
	  			contentType:"application/json",
	  			success: function(result) {
	  				//alert("result" + JSON.stringify(result));
	  				if(result != null){
	  					priUrl = result.priUrl;
	  					$("#txtInterfaceName").val(result.name).validatebox('validate');
	  					//$("#comboxInterfaceCode").combobox("setValue", result.code);
	  					$("#interfaceCode").val(result.code).validatebox('validate');
	  					//alert(result.fieldId + result.fieldSystemId);
	  					$("#comboxFieldName").combobox("setValue", result.filedId);
	  					$("#comboxSystemName").combobox("setValue", result.filedSystemId);
	  					$("#interfaceVserion").val(result.version);
	  					$("#comboxInterfaceDataFormat").combobox("setValue", result.dataFormate);
	  					
	  					/*$("#bundleName").val(result.budleName);*/
	  					
	  					reBackData(row, result.visibleFieldSystems);
	  					//alert(result.DefinedBundles);
	  					/*reBackBundleJarName(row, result.DefinedBundles);*/
	  					if(result.bundleType == '0'){
	  						$("#interfaceOriginAddress").val(result.priUrl).validatebox('validate');
	  					}else{
	  						$("#interfaceOriginAddress").val("helloWord").validatebox('validate');
	  					}
	  					$("#interfaceDescriptions").val(result.desc);
	  					//var data = data.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
	  					if(result.requestMess != null && result.requestMess != ""){
	  						$("#requestParametersMsg").val(result.requestMess.replace(/&lt;/g, "<").replace(/&gt;/g, ">"));
	  					}
	  					if(result.returnMess != null && result.returnMess != ""){
	  						$("#responseParametersMsg").val(result.returnMess.replace(/&lt;/g, "<").replace(/&gt;/g, ">"));
	  					}
	  					$("#overTimeSetting").val(result.overtime).validatebox('validate');
	  					
	  					$("#alarmId").val(result.interfaceRequestQuantity[0].requestQuantityId);
	  					$("#alarmThreshold").val(result.interfaceRequestQuantity[0].requestThreshold).validatebox('validate');
	  					$("#alarmMax").val(result.interfaceRequestQuantity[0].requestMax).validatebox('validate');
	  					
	  					$("#comboxIsPublic").combobox("setValue", result.ifPublic);
	  					$("#comboxOperationType").combobox("setValue", result.operationType);
	  					$("input[type=radio][value="+result.transportProtocol+"]").attr("checked",'checked');
	  			    	var chooseVal = $("#comboxIsPublic").combobox('getValue');
	  			    	if(chooseVal=="0"){
	  			    		$("#li_visible").css("display","block");
	  			    	}else{
	  			    		$("#li_visible").css("display","none");
	  			    	}
	  			    	
	  			    	//var authType = result.authType;
	  			    	//var data = $("#comboxAuthencationMode").combobox("getData");
	  			    	//深度拷贝
	  			    	var data = new Array();
	  			    	for(var i = 0; i < authModeTotal.length; i++){
	  			    		var authObject = new Object();
	  			    		authObject.valueName = authModeTotal[i].valueName;
	  			    		authObject.valueCode = authModeTotal[i].valueCode;
	  			    		data.push(authObject);
	  			    	}
	  			    	if(result.type == "1"){
	  			    		//webservice
	  			    		for(var i=0; i<data.length; i++)  
	  				        {  
	  				            var curObj = data[i];  
	  				            if(curObj.valueCode === "2")  
	  				            {  
	  				            	data.splice(i,1);  
	  				            }  
	  				        }
	  			    		$("#comboxAuthencationMode").combobox("loadData", data);
	  			    		$("#comboxAuthencationMode").combobox("setValue", result.authType);
	  			    	}else if(result.type == "2"){
	  			    		//rest
	  			    		for(var i=0; i<data.length; i++)  
	  				        {  
	  				            var curObj = data[i];  
	  				            if(curObj.valueCode === "3")  
	  				            {  
	  				            	data.splice(i,1);  
	  				            }  
	  				        }
	  			    		$("#comboxAuthencationMode").combobox("loadData", data);
	  			    		$("#comboxAuthencationMode").combobox("setValue", result.authType);
	  			    	}
	  					
	  					if(result.type == "1"){
	  						//webservice
	  						$("#li_soap").css("display","block"); 
	  						$("#interfaceReqMsg").css("display","block");
	  						$("#comboxSoapProtocol").combobox("setValue", result.contentType);
	  						
	  						$("#requestMethod").css("display", "none");
	  					}else if(result.type == "2"){
	  						//rest
	  						$("#li_soap").css("display","none"); 
	  						$("#interfaceReqMsg").css("display","none");

	  						$("#requestMethod").css("display", "block");
		  					$("#comboxInterfaceReqeustMethod").combobox("setValue", result.request);
	  					}else{
	  						
	  					}
	  					//$("#comboxBundleModel").combobox("setValue", result.bundleType);
	  					if(result.bundleType == "0"){
	  						$("#li_bundleName").css("display","none");
	  						$("#li_bundle").css("display","none");
	  						$(".li_depPackage").css("display","none");
	  						$("#interfaceAddress").css("display","block");
	  					}else{
	  						$("#li_bundleName").css("display","block");
	  						$("#li_bundle").css("display","block");
	  						$(".li_depPackage").css("display","block");
	  						$("#interfaceAddress").css("display","none");
	  						$("#bundleName").val(result.budleName);
	  						/*reBackBundleJarName(row, result.DefinedBundles);*/
	  						reBackBundleJarNameSingle(row, result.DefinedBundles);
	  					}
	  					
	  					//请求参数回显
	  					for(var i = 0; i < result.interfaceParameter.length; i++){
	  						//alert("result" + JSON.stringify(result.interfaceParameter[0]));
	  						//alert(result.interfaceParameter[i].type);
	  						if(result.interfaceParameter[i].paramType == "1"){
			  					if($(".interfaceDataAdd").form("validate")){
			  						var ParamId = result.interfaceParameter[i].paramId;
			  			            var reqParameterName = result.interfaceParameter[i].paramName;
			  						var reqParameterType = result.interfaceParameter[i].paramDataType;
			  						var reqParameterTypeDispaly;
			  						if(reqParameterType == "0"){
			  							reqParameterTypeDispaly = "String";
			  						}else if(reqParameterType == "1"){
			  							reqParameterTypeDispaly = "double";
			  						}else if(reqParameterType == "2"){
			  							reqParameterTypeDispaly = "int";
			  						}else if(reqParameterType == "3"){
			  							reqParameterTypeDispaly = "boolean";
			  						}else if(reqParameterType == "4"){
			  							reqParameterTypeDispaly = "byte";
			  						}else if(reqParameterType == "5"){
			  							reqParameterTypeDispaly = "short";
			  						}else if(reqParameterType == "6"){
			  							reqParameterTypeDispaly = "long";
			  						}else if(reqParameterType == "7"){
			  							reqParameterTypeDispaly = "float";
			  						}else if(reqParameterType == "8"){
			  							reqParameterTypeDispaly = "JSON";
			  						}else if(reqParameterType == "9"){
			  							reqParameterTypeDispaly = "object";
			  						}else if(reqParameterType == "10"){
			  							reqParameterTypeDispaly = "File";
			  						}
			  						
			  						
			  						var reqParameterIsMust = result.interfaceParameter[i].isNeed;
			  						var reqParameterIsMustValue;
			  						
			  						var reqParameterIsMustDispaly;
			  						if(reqParameterIsMust == "1"){
			  							reqParameterIsMustValue = "1";
			  							reqParameterIsMustDispaly = "是";
			  						}else{
			  							reqParameterIsMustValue = "0";
			  							reqParameterIsMustDispaly = "否";
			  						}
			  						var reqParameterDefaultValue = result.interfaceParameter[i].paramDefaultValue;
			  						/*var reqParameterDefaultValue = "sdfsd";*/
			  						var reqParameterDes = result.interfaceParameter[i].paramDes;
			  						if(reqParameterName != '' && reqParameterType !== '')
			  						{
			  							var tableHtml = '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" style="display:none" class="ParamId">' + ParamId + '</td><td width="16.7%" class="reqParameterName"><p class="txtP" title="' + reqParameterName + '">' + reqParameterName + '</p></td><td width="16.7%" class="comboxReqParameterType" data-val="' + reqParameterType + '"><p class="txtP" title="' + reqParameterTypeDispaly + '">' + reqParameterTypeDispaly + '</p></td><td width="16.7%" class="reqParameterIsMust" data-val="' + reqParameterIsMustValue + '"><p class="txtP" title="' + reqParameterIsMustDispaly + '">' + reqParameterIsMustDispaly + '</p></td><td width="16.7%" class="reqParameterDefaultValue"><p class="txtP" title="' + reqParameterDefaultValue + '">' + reqParameterDefaultValue + '</p></td><td width="16.7%" class="reqParameterDes"><p class="txtP" title="' + reqParameterDes + '">' + reqParameterDes + '</p></td><td width="16.7%" class="operation_table"><a href="javascript:void(0);" class="change_title">更改</a><a href="javascript:void(0);" class="del_title">删除</a></td></tr>';
			  							$(".add").find("tr").eq(0).after(tableHtml);
			  							$("#reqParamId, #reqParameterName, #comboxReqParameterType, #reqParameterIsMust, #reqParameterDefaultValue, #reqParameterDes").val('');
			  						}else
			  						{
			  							$.messager.alert('警告', '<p>请填写完整！</p>', 'warning');
			  						}
			  					}
			  					else
			  					{
			  						$(".interfaceDataAdd .validatebox-invalid").eq(0).focus();
			  					}
		  					
	  						}else{
	  							if($(".responseParametersForm").form("validate")){
	  								var repParamId = result.interfaceParameter[i].paramId;
	  					            var repParameterName = result.interfaceParameter[i].paramName;
	  					            
	  								var repParameterType = result.interfaceParameter[i].paramDataType;
	  								var repParameterTypeDispaly;
	  								
	  								if(repParameterType == "0"){
	  									repParameterTypeDispaly = "String";
			  						}else if(repParameterType == "1"){
			  							repParameterTypeDispaly = "double";
			  						}else if(repParameterType == "2"){
			  							repParameterTypeDispaly = "int";
			  						}else if(repParameterType == "3"){
			  							repParameterTypeDispaly = "boolean";
			  						}else if(repParameterType == "4"){
			  							repParameterTypeDispaly = "byte";
			  						}else if(repParameterType == "5"){
			  							repParameterTypeDispaly = "short";
			  						}else if(repParameterType == "6"){
			  							repParameterTypeDispaly = "long";
			  						}else if(repParameterType == "7"){
			  							repParameterTypeDispaly = "float";
			  						}else if(repParameterType == "8"){
			  							repParameterTypeDispaly = "JSON";
			  						}else if(repParameterType == "9"){
			  							repParameterTypeDispaly = "object";
			  						}else if(repParameterType == "10"){
			  							repParameterTypeDispaly = "File";
			  						}
	  								
	  								
	  								var repParameterDes = result.interfaceParameter[i].paramDes;
	  								if(repParameterName != '' && repParameterType !== '')
	  								{
	  									var tableHtml = '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" style="display:none" class="repParamId">' + repParamId + '</td><td width="25%" class="repParameterName"><p class="txtPP" title="' + repParameterName + '">' + repParameterName + '</p></td><td width="25%" class="comboxRepParameterType" data-val="' + repParameterType + '"><p class="txtPP" title="' + repParameterTypeDispaly + '">' + repParameterTypeDispaly + '</p></td><td width="25%" class="repParameterDes"><p class="txtPP" title="' + repParameterDes + '">' + repParameterDes + '</p></td><td width="25%" class="operation_table"><a href="javascript:void(0);" class="change_title_rep">更改</a><a style="margin-left:10px;" href="javascript:void(0);" class="del_title_rep">删除</a></td></tr>';
	  									$(".add_rep").find("tr").eq(0).after(tableHtml);
	  									$("#repParamId, #repParameterName, #comboxRepParameterType, #repParameterDes").val('');
	  								}else
	  								{
	  									$.messager.alert('警告', '<p>请填写完整！</p>', 'warning');
	  								}
	  							}
	  							else
	  							{
	  								$(".interfaceDataAdd_rep .validatebox-invalid").eq(0).focus();
	  							}
	  						}
		  					
	  					
	  					}
	  					$("#win").window('setTitle', result.name + '-修改');
	  					$('#win').window('open');
	  					
	  					
	  					//$("#interfaceName").val(result.http.name);
	  				}
	  			},
	  			error: function() {
	  				/*$.messager.alert('错误','<p>服务异常，修改领域信息失败，请稍后重试或联系管理员!</p>', 'error');*/
	  			}
	  		});
	}
	
	//升级版本号
	function upVersion(maxVersion){
		var version = parseInt(maxVersion.substring(1, maxVersion.length - 2)) + 1;
		return version;
	}
	
	
	//版本升级数据回显
	function httpVersionUpgrade(row, maxVersion){
		var reqRows = $(".add").find("tr").size();
		for(var i = reqRows; i >　1; i--){
			$(".add").find("tr").eq(i - 1).remove();
		}
		
		var repRows = $(".add_rep").find("tr").size();
		for(var j = repRows; j >　1; j--){
			$(".add_rep").find("tr").eq(j - 1).remove();
		}
		
		var version = upVersion(maxVersion);
		
		var jsonData = {
				id:row.interfaceId
			}
			/* 根据接口id获取接口信息进行表单回显  */
			$.ajax({
	  			type: "get",
	  			url: BASE_URL_HTTP_INTERFACE + '/findIfById' + '?v=' + Math.random(),
	  			dataType:'json',
	  			data: jsonData,
	  			contentType:"application/json",
	  			success: function(result) {
	  				//alert("result" + JSON.stringify(result));
	  				if(result != null){
	  					priUrl = result.priUrl;
	  					$("#txtInterfaceName").val(result.name).validatebox('validate');
	  					//$("#comboxInterfaceCode").combobox("setValue", result.code);
	  					$("#interfaceCode").val(result.code).validatebox('validate');
	  					//alert(result.fieldId + result.fieldSystemId);
	  					$("#comboxFieldName").combobox("setValue", result.filedId);
	  					$("#comboxSystemName").combobox("setValue", result.filedSystemId);
	  					//$("#interfaceVserion").val(version);
	  					$("#interfaceVserion").val("v" + version + ".0");
	  					$("#comboxInterfaceDataFormat").combobox("setValue", result.dataFormate);
	  					
	  					//$("#bundleName").val(result.budleName);
	  					
	  					reBackData(row, result.visibleFieldSystems);
	  					//alert(result.DefinedBundles);
	  					//reBackBundleJarName(row, result.DefinedBundles);
	  					$("#packageJarNameId").val("");
	  					$("#packageJarName").val("");
	  					if(result.bundleType == '0'){
	  						$("#interfaceOriginAddress").val(result.priUrl).validatebox('validate');
	  					}else{
	  						$("#interfaceOriginAddress").val('helloWord').validatebox('validate');
	  					}
	  					$("#interfaceDescriptions").val(result.desc);
	  					
	  					$("#requestParametersMsg").val("");
	  					$("#responseParametersMsg").val("");
	  					//var data = data.replace(/&lt;/g, "<").replace(/&gt;/g, ">");
	  					/*$("#requestParametersMsg").val(result.requestMess.replace(/&lt;/g, "<").replace(/&gt;/g, ">"));
	  					$("#responseParametersMsg").val(result.returnMess.replace(/&lt;/g, "<").replace(/&gt;/g, ">"));*/
	  					$("#overTimeSetting").val(result.overtime).validatebox('validate');
	  					
	  					$("#alarmId").val(result.interfaceRequestQuantity[0].requestQuantityId);
	  					$("#alarmThreshold").val(result.interfaceRequestQuantity[0].requestThreshold).validatebox('validate');
	  					$("#alarmMax").val(result.interfaceRequestQuantity[0].requestMax).validatebox('validate');
	  					
	  					$("#comboxIsPublic").combobox("setValue", result.ifPublic);
	  					$("#comboxOperationType").combobox("setValue", result.operationType);
	  					$("input[type=radio][value="+result.transportProtocol+"]").attr("checked",'checked');
	  			    	var chooseVal = $("#comboxIsPublic").combobox('getValue');
	  			    	if(chooseVal=="0"){
	  			    		$("#li_visible").css("display","block");
	  			    	}else{
	  			    		$("#li_visible").css("display","none");
	  			    	}
	  			    	
	  			    	
	  					/*$("#comboxAuthencationMode").combobox("setValue", result.authType);
	  					*/
	  			    	//深度拷贝
	  			    	var data = new Array();
	  			    	for(var i = 0; i < authModeTotal.length; i++){
	  			    		var authObject = new Object();
	  			    		authObject.valueName = authModeTotal[i].valueName;
	  			    		authObject.valueCode = authModeTotal[i].valueCode;
	  			    		data.push(authObject);
	  			    	}
	  			    	if(result.type == "1"){
	  			    		//webservice
	  			    		for(var i=0; i<data.length; i++)  
	  				        {  
	  				            var curObj = data[i];  
	  				            if(curObj.valueCode === "2")  
	  				            {  
	  				            	data.splice(i,1);  
	  				            }  
	  				        }
	  			    		$("#comboxAuthencationMode").combobox("loadData", data);
	  			    		$("#comboxAuthencationMode").combobox("setValue", result.authType);
	  			    	}else if(result.type == "2"){
	  			    		//rest
	  			    		for(var i=0; i<data.length; i++)  
	  				        {  
	  				            var curObj = data[i];  
	  				            if(curObj.valueCode === "3")  
	  				            {  
	  				            	data.splice(i,1);  
	  				            }  
	  				        }
	  			    		$("#comboxAuthencationMode").combobox("loadData", data);
	  			    		$("#comboxAuthencationMode").combobox("setValue", result.authType);
	  			    	}
	  			    	
	  			    	
	  					if(result.type == "1"){
	  						//$("#div_soap").show();
	  						$("#li_soap").css("display","block"); 
	  						$("#interfaceReqMsg").css("display","block");
	  						$("#comboxSoapProtocol").combobox("setValue", result.contentType);
	  						
	  						$("#requestMethod").css("display", "none");
	  						
	  					}else if(result.type == "2"){
	  						$("#li_soap").css("display","none"); 
	  						$("#interfaceReqMsg").css("display","none");
	  						
	  						$("#requestMethod").css("display", "block");
	  						$("#comboxInterfaceReqeustMethod").combobox("setValue", result.contentType);
	  					}else{
	  						
	  					}
	  					//$("#comboxBundleModel").combobox("setValue", result.bundleType);
	  					if(result.bundleType == "0"){
	  						$("#li_bundleName").css("display","none");
	  						$("#li_bundle").css("display","none");
	  						$(".li_depPackage").css("display","none");
	  						$("#interfaceAddress").css("display","block");
	  					}else{
	  						$("#li_bundleName").css("display","block");
	  						$("#li_bundle").css("display","block");
	  						$(".li_depPackage").css("display","block");
	  						$("#interfaceAddress").css("display","none");
	  					}
	  					
	  					
	  					
	  					$("#win").window('setTitle', result.name + '-版本升级');
	  					$('#win').window('open');
	  					
	  					
	  					//$("#interfaceName").val(result.http.name);
	  				}
	  			},
	  			error: function() {
	  				/*$.messager.alert('错误','<p>服务异常，修改领域信息失败，请稍后重试或联系管理员!</p>', 'error');*/
	  			}
	  		});
	}
	
	
	
	
	
	
	//接口请求数据项数据转JSON
	var columnDefinitions;
	function interfaceData()
	{
		var table_con = $(".add tbody").children().clone();
		$(".interfaceData tbody").html('<tr><th width="20%">reqParamId</th><th width="20%">reqParameterName</th><th width="20%">comboxReqParameterType</th><th width="20%">reqParameterIsMust</th><th width="20%">reqParameterDefaultValue</th><th width="20%">reqParameterDes</th></tr>');
		$(".interfaceData tbody").append(table_con);
		$(".interfaceData tr:eq(1)").remove();
		for(var i = 1, len = $(".interfaceData tr").length; i < len; i++)
		{
			$(".interfaceData tr:eq(" + i + ") td:eq(2)").text($(".interfaceData tr:eq(" + i + ") td:eq(2)").attr("data-val"));
			$(".interfaceData tr:eq(" + i + ") td:eq(3)").text($(".interfaceData tr:eq(" + i + ") td:eq(3)").attr("data-val"));
		}		
		$(".interfaceData tr td:last-child").remove();
		columnDefinitions = $('.interfaceData').tableToJSON(); 
		return columnDefinitions;
	}
	
	
	//接口返回数据项数据转JSON
	var columnDefinitions_rep;
	function interfaceData_rep()
	{
		var table_con = $(".add_rep tbody").children().clone();
		$(".interfaceData_rep tbody").html('<tr><th width="20%">repParamId</th><th width="20%">repParameterName</th><th width="20%">comboxRepParameterType</th><th width="20%">repParameterDes</th></tr>');
		$(".interfaceData_rep tbody").append(table_con);
		$(".interfaceData_rep tr:eq(1)").remove();
		for(var i = 1, len = $(".interfaceData_rep tr").length; i < len; i++)
		{
			$(".interfaceData_rep tr:eq(" + i + ") td:eq(2)").text($(".interfaceData_rep tr:eq(" + i + ") td:eq(2)").attr("data-val"));
		}		
		$(".interfaceData_rep tr td:last-child").remove();
		columnDefinitions_rep = $('.interfaceData_rep').tableToJSON(); 
		return columnDefinitions_rep;
	}
	
	
	//获取所有表单数据
	var interfaceDatas;
	function getFormDatas(){
			var row = $('#datagrid').datagrid('getSelected');
			//alert(row.type + row.bundleType);
			var id = row.interfaceId;
			var interfaceName = $.trim($("#txtInterfaceName").val());
			var interfaceCode = $("#interfaceCode").val();
			var soapProtocol = "";
			var interfaceRequestMethod = "";
			if(row.type == "1"){
				//Webservice
				soapProtocol = $("#comboxSoapProtocol").combobox("getValue");
				
			}else{
				//Rest
				interfaceRequestMethod = $("#comboxInterfaceReqeustMethod").combobox("getValue");
			}
			
			var fieldId = $("#comboxFieldName").combobox("getValue");
			var systemId = $("#comboxSystemName").combobox("getValue");
			var interfaceVersion = $.trim($("#interfaceVserion").val());
			var interfaceDataFormat = $("#comboxInterfaceDataFormat").combobox("getValue");
			//var bundleMode = $("#comboxBundleModel").combobox("getValue");
			var interfaceOriginAddress;
			if(isModify){
				interfaceOriginAddress = $.trim($("#interfaceOriginAddress").val());
			}else{
				//alert(priUrl +　interfaceOriginAddress);
				if(row.bundleType == "0"){
					if(priUrl == interfaceOriginAddress){
						$.messager.alert('警告', '<p>版本升级后，接口原始地址未改变!</p>', 'warning');
					}else{
						interfaceOriginAddress = $.trim($("#interfaceOriginAddress").val());
					}
				}else{
					
				}
			}
			
			
			var interfaceDes = $.trim($("#interfaceDescriptions").val());

  			var requestParameterMsg  = $.trim($("#requestParametersMsg").val());
  			if(row.type == "1"){
  				if(requestParameterMsg != "")
  				{
  				}else
  				{
  					$.messager.alert('警告', '<p>请求参数报文不能为空!</p>', 'warning');
  					return false;
  				}
  			}
  			
  			var requestParameters  = interfaceData();
  			
  			var responseParametersMsg = $.trim($("#responseParametersMsg").val());
  			/*if(responseParametersMsg != "")
			{
			}else
			{
				$.messager.alert('警告', '<p>返回参数报文不能为空!</p>', 'warning');
				return false;
			}*/
  			var responseParameters = interfaceData_rep();
  			var alarmId = $.trim($("#alarmId").val());
  			var alarmThreshold = parseInt($.trim($("#alarmThreshold").val()));
  			var alarmMax = parseInt($.trim($("#alarmMax").val()));
  			if(alarmThreshold > alarmMax){
  				$.messager.alert('警告', '<p>请求告警阀值不能大于请求最大值!</p>', 'warning');
				return false;
  			}
  			var overTimeSetting = $.trim($("#overTimeSetting").val());
  			var isPublic = $("#comboxIsPublic").combobox("getValue");
  			var operationType = $("#comboxOperationType").combobox("getValue");
  			var authencationMode = $("#comboxAuthencationMode").combobox("getValue");
  			var transportProtocol = $('input[name="transportProtocol"]:checked ').val();
  			
  			
  			var interfaceType = row.type;
				
  			interfaceDatas = {
  				id:id,
				interfaceName:interfaceName,
	  			interfaceCode:interfaceCode,
	  			fieldId:fieldId,
	  			systemId:systemId,
	  			interfaceVersion:interfaceVersion,
	  			interfaceDataFormat:interfaceDataFormat,
	  			interfaceRequestMethod:interfaceRequestMethod,
	  			//bundleMode:bundleMode,
	  			//bundleName:bundleName,
	  			interfaceOriginAddress:interfaceOriginAddress,
	  			interfaceDes:interfaceDes,
				requestParameterMsg:requestParameterMsg,
				responseParametersMsg:responseParametersMsg,
				alarmId:alarmId,
				alarmThreshold:alarmThreshold,
				alarmMax:alarmMax,
				overTimeSetting:overTimeSetting,
				isPublic:isPublic,
				operationType:operationType,
				transportProtocol:transportProtocol,
				authencationMode:authencationMode,
				soapProtocol:soapProtocol,
				interfaceType:interfaceType,
				requestParameters:requestParameters,
				responseParameters:responseParameters,
				httpBundleId:httpBundleId
			}
  			
  			var dependsPackagesStr = $("#strdependsPackages").val();
  			if(dependsPackagesStr != ""){
	  			if(dependsPackagesStr.indexOf(",") != -1){
	  				interfaceDatas["dependsPackageIds"] = dependsPackagesStr == ""? []:dependsPackagesStr.split(",");
	  			}else{
	  				interfaceDatas["dependsPackageIds"] = [dependsPackagesStr];
	  			}
  			}else{
  				interfaceDatas["dependsPackageIds"] = [];
  			}
  			
  			
  			var fieldSystemsStr = $("#strFieldSystems").val();
  			if(fieldSystemsStr != ""){
	  			if(fieldSystemsStr.indexOf(",") != -1){
	  				interfaceDatas["fieldSystemIds"] = fieldSystemsStr == ""? []:fieldSystemsStr.split(",");
	  			}else{
	  				interfaceDatas["fieldSystemIds"] = [fieldSystemsStr];
	  			}
  			}else{
  				interfaceDatas["fieldSystemIds"] = [];
  			}
  			
  			if(isModify){
  				//更新
	  			if(deleteParamIds != ""){
		  			if(deleteParamIds.indexOf(",") != -1){
		  				interfaceDatas["deleteParamIds"] = deleteParamIds == ""?[]:deleteParamIds.split(",");
		  			}else{
		  				interfaceDatas["deleteParamIds"] = [deleteParamIds];
		  			}
	  			}else{
	  				interfaceDatas["deleteParamIds"] = []
	  			}
  			}else{
  				//版本升级
  			}
  			
  			
  			if(row.bundleType == "0"){
  				
			}else{
				var packageJarNames = $.trim($("#packageJarName").val());
				if(packageJarNames != "")
				{
				}else
				{
					$.messager.alert('警告', '<p>部署包名称不能为空!</p>', 'warning');
					return false;
				}
				if(packageJarNames != null && packageJarNames != ""){
					if(packageJarNames.indexOf(",") != -1){
						//alert(packageJarNames);
						interfaceDatas["packageJarNames"] = packageJarNames == ""? []:packageJarNames.split(",");
					}else{
						interfaceDatas["packageJarNames"] = [packageJarNames];
					}
				}else{
					interfaceDatas["packageJarNames"] = [];
				}
				
				if(isModify){
					//更新
	  				if(isUpdate){
	  					bundleJarIds = $("#packageJarNameId").val();
	  					interfaceDatas["bundleJarIds"] = [bundleJarIds];
	  				}else{
	  					interfaceDatas["bundleJarIds"] = [];
	  				}
	  				/*
					if(bundleJarIds != null && bundleJarIds != ""){
						if(bundleJarIds.indexOf(",") != -1){
							interfaceDatas["bundleJarIds"] = bundleJarIds == ""? []:bundleJarIds.split(",");
						}else{
							interfaceDatas["bundleJarIds"] = [bundleJarIds];
						}
					}else{
						interfaceDatas["bundleJarIds"] = [];													
					}*/
				}else{
					//版本升级
				}
				
			}
  			
  			return interfaceDatas;
	}
	
	
	
	/* 树 */
	//点击分配打开用户授权修改页面
	function onOpenEdit(rowIndex) {
		var rowData = $('#datagrid').datagrid('getRows')[parseInt(rowIndex, 10)];
		$.ajax({
			type: "get",
			url: BASE_URL_HTTP_INTERFACE + "/getFieldSystemRoot?id="+rowData.id,
			dataType:"json",/* 
			async:false, */
			contentType: "application/json",
			success: function(data) {
				//fieldSystems = data;
				reBackData(rowData,data);
			},
			error: function() {
				$.messager.alert('错误','<p>服务异常，获取用户所管理的系统失败，请稍后重试!</p>','error');
			}
		});	
		
	}
	
	//点击分配后要回显用户相关数据
	function reBackData(rowData,data){
		
		var systemsInfo = getSystemsStrFromSyslist(data);
		g_currSystemsStr = systemsInfo.names;
		$("#strFieldSystems").val(systemsInfo.ids);
		$("#system").val(systemsInfo.names);
	}
	
	/*function reBackBundleJarName(rowData, DefinedBundleDatas){
		$("#uploadTable tbody").empty();
		var definedBundleNamesStr = "";
		var definedBundleNameIdsStr = "";
		var dependDefinedBundleNamesStr = "";
		var dependDefinedBundleNameIdsStr = "";
		for(var i = 0, len=DefinedBundleDatas.length; i < len; ++i)
		{
			if(!DefinedBundleDatas[i])
			{
				continue;
			}
			var definedBundleName = DefinedBundleDatas[i].bundleJarName;
			var definedBundleNameId = DefinedBundleDatas[i].bundleId;
			if(DefinedBundleDatas[i].isDefinedBundle == "1"){
				httpBundleId = "";
				httpBundleId = DefinedBundleDatas[i].bundleId;
				definedBundleNamesStr += (definedBundleNamesStr == ""? "":",") + DefinedBundleDatas[i].bundleJarName;
				definedBundleNameIdsStr += (definedBundleNameIdsStr == ""? "":",") + DefinedBundleDatas[i].bundleId;
				
				
				$("#uploadTable tbody").append("<tr name='"+DefinedBundleDatas[i].bundleId+"'>" +
											"<td>"+DefinedBundleDatas[i].bundleJarName+"</td>"+
											"<td>已上传</td>"+
											"<td>无</td>" +
											"<td><input type=\"checkbox\" name=\"is_update\" value='"+DefinedBundleDatas[i].bundleId+"'/></td></tr>");
				
	
				$("#uploadTable, #content").css("display", "block");
			}else{
				dependDefinedBundleNamesStr += (dependDefinedBundleNamesStr == ""? "":",") + DefinedBundleDatas[i].bundleName;
				dependDefinedBundleNameIdsStr += (dependDefinedBundleNameIdsStr == ""? "":",") + DefinedBundleDatas[i].bundleCode;
				
				
			}
		}
		
		//alert(definedBundleNamesStr);
		$("#packageJarName").val(definedBundleNamesStr);
		$("#strdependsPackages").val(dependDefinedBundleNameIdsStr);
		$("#dependsPackages").val(dependDefinedBundleNamesStr);
		
		
	}*/
	function reBackBundleJarNameSingle(rowData, DefinedBundleDatas){
		var definedBundleNamesStr = "";
		var definedBundleNameIdsStr = "";
		var dependDefinedBundleNamesStr = "";
		var dependDefinedBundleNameIdsStr = "";
		for(var i = 0, len=DefinedBundleDatas.length; i < len; ++i)
		{
			if(!DefinedBundleDatas[i])
			{
				continue;
			}
			var definedBundleName = DefinedBundleDatas[i].bundleJarName;
			var definedBundleNameId = DefinedBundleDatas[i].bundleId;
			if(DefinedBundleDatas[i].isDefinedBundle == "1"){
				httpBundleId = "";
				httpBundleId = DefinedBundleDatas[i].bundleId;
				definedBundleNamesStr += (definedBundleNamesStr == ""? "":",") + DefinedBundleDatas[i].bundleJarName;
				definedBundleNameIdsStr += (definedBundleNameIdsStr == ""? "":",") + DefinedBundleDatas[i].bundleId;
				
				
			}else{
				dependDefinedBundleNamesStr += (dependDefinedBundleNamesStr == ""? "":",") + DefinedBundleDatas[i].bundleName;
				dependDefinedBundleNameIdsStr += (dependDefinedBundleNameIdsStr == ""? "":",") + DefinedBundleDatas[i].bundleCode;
				
				
			}
		}
		
		//alert(definedBundleNamesStr);
		$("#packageJarNameId").val(definedBundleNameIdsStr);
		$("#packageJarName").val(definedBundleNamesStr);
		$("#strdependsPackages").val(dependDefinedBundleNameIdsStr);
		$("#dependsPackages").val(dependDefinedBundleNamesStr);
	}

	function onCancleEdit(){
		$('#winEdit').window('close');
	}
	
	function onSearch(){
		$('#datagrid').datagrid('reload');
	}
	
	//通过领域系统对象数组转成系统字符串
	function getSystemsStrFromSyslist(fieldSystemsArr) {
		var systemsStr = "";
		var systemIdsStr = "";
		for(var i = 0, len=fieldSystemsArr.length; i < len; ++i)
		{
			if(!fieldSystemsArr[i])
			{
				continue;
			}
			var fieldName = fieldSystemsArr[i].fieldName;
			var systemName = fieldSystemsArr[i].fieldSystemName;
			systemIdsStr += (systemIdsStr == ""? "":",") + fieldSystemsArr[i].fieldSystemId;
			systemsStr += systemName + (i == len-1? "":",");
		}
		return {
			ids:systemIdsStr,
			names:systemsStr
		};
	}
	
	//通过字符串获取系统列表
	function getSystemListFromStr(fieldSystemsStr) {
		if(!fieldSystemsStr)
		{
			return [];
		}
		var fieldSystemList = fieldSystemsStr.split(",");
		var systemList = [];
		for(var i = 0, len=fieldSystemList.length; i < len; ++i)
		{
			if(!fieldSystemList[i])
			{
				continue;
			}
			var systemName = fieldSystemList[i].split("-")[1];
			if(systemName)
			{
				systemList.push(systemName);
			}
		}
		return systemList;
	}

	//通过字符串获取构造领域系统的树节点信息
	function getFieldSystemNodesFromStr(fieldSystemsStr) {
		if(!fieldSystemsStr)
		{
			return [];
		}
		var fieldSystemList = fieldSystemsStr.split(",");
		var fieldList = [];
		var systemNodeList = [];
		for(var i = 0, len=fieldSystemList.length; i < len; ++i)
		{
			if(!fieldSystemList[i])
			{
				continue;
			}
			var fieldName = fieldSystemList[i].split("-")[0];
			var systemName = fieldSystemList[i].split("-")[1];
			if(fieldName)
			{
				var tempNode = {};
				var j = 0;
				for(; j < fieldList.length; ++j)
				{
					if(fieldList[j].text == fieldName)
					{
						if(systemName)
						{
							fieldList[j].children.push({
								text:systemName,
								children:[],
								nodeType:"fieldSystem"
							});
						}
						break;
					}
				}
				if(j == fieldList.length)
				{
					tempNode.text = fieldName;
					tempNode.nodeType = "field";
					tempNode.children = [];
					if(systemName)
					{
						tempNode.children.push({
							text:systemName,
							children:[],
							nodeType:"fieldSystem"
						});
					}
					fieldList.push(tempNode);
				}
			}
			
		}
		return fieldList;
	}
	
	//通过领域系统对象数组转换成树节点信息
	function getFieldSystemNodesFromArr(fieldSystemsArr) {
		if(!fieldSystemsArr)
		{
			return [];
		}
		var fieldNodes = [];
		for(var i = 0, len=fieldSystemsArr.length; i < len; ++i)
		{
			if(!fieldSystemsArr[i])
			{
				continue;
			}
			var fieldName = fieldSystemsArr[i].fieldName;
			var systemName = fieldSystemsArr[i].fieldSystemName;
			if(fieldName)
			{
				var tempNode = {};
				var j = 0;
				for(; j < fieldNodes.length; ++j)
				{
					if(fieldNodes[j].text == fieldName)
					{
						if(systemName)
						{
							fieldNodes[j].children.push({
								text:systemName,
								children:[],
								nodeType:"fieldSystem"
							});
						}
						break;
					}
				}
				if(j == fieldNodes.length)
				{
					tempNode.text = fieldName;
					tempNode.nodeType = "field";
					tempNode.children = [];
					if(systemName)
					{
						tempNode.children.push({
							text:systemName,
							children:[],
							nodeType:"fieldSystem"
						});
					}
					fieldNodes.push(tempNode);
				}
			}
		}
		return fieldNodes;
	}
	
	//显示所属系统
	function onShowDetail(rowIndex) {
		var rowData = $('#datagrid').datagrid('getRows')[parseInt(rowIndex, 10)];
		$.ajax({
			type: "get",
			url: BASE_URL_USER_SEARCH + "/getFieldSystemRoot?id="+rowData.id,
			dataType:"json",
			contentType: "application/json",
			success: function(data) {
				//fieldSystems = data;
				
				var fieldSystemsNodes = getFieldSystemNodesFromArr(data);
				$("#sys_show_tt").tree("loadData", fieldSystemsNodes);
				$("#sys_show_tt > li > ul > li > .tree-node > .tree-file").css("background","url('../../images/st_folder.png') no-repeat 2px 2px");
				$("#system_show").window('setTitle',rowData.userCode + '所属系统');
				$('#system_show').window('open');
			},
			error: function() {
				$("#instance_save").linkbutton("enable");
				$("#instance_save .l-btn-text").text("保存");
				$.messager.alert('错误','<p>服务异常，获取用户所管理的系统失败，请稍后重试!</p>','error');
			}
		});		
	}
	
	
	function setChecked(sysName) {
		if(!sysName)
		{
			return;
		}
		$("#tt li .tree-node").each(function(){
			if($(".tree-title", $(this)).text() == sysName)
			{
				$('#tt').tree('check', this);
				return false;
			}
		});
		
	}
	
	function setCheckedList(sysNameArr)
	{
		if(sysNameArr && sysNameArr.length)
		{
			for(var i = 0, len = sysNameArr.length; i < len; ++i)
			{
				setChecked(sysNameArr[i]);
			}
		}
	}
	
	function reSetTree(){
		$('#system_selection').window('open');	
		var txtInterface = $("#system").val().split(",")[0];
	
		if(txtInterface !== '')
		{
			$("#systemName").val(txtInterface);
			choose_tree();
		}
		else
		{
			$("#systemName").val('');
			$(".tree_con").scrollTop(0);
			var row = $('#tt li .tree-node');  
			row.removeClass('tree-node-selected');
		}
		
		var checkedNodes = $("#tt").tree("getChecked");
		if(checkedNodes)
		{
			$.each(checkedNodes, function(index, node) {
				$("#tt").tree("uncheck", node.target);
			});
		}
		
		var currSystemsStr = $("#system").val();
		if(currSystemsStr != '')
		{
			setCheckedList(currSystemsStr.split(","));
		}
	}
	
	
	function choose_tree()
	{
		$('#tt').tree('expandAll');
		if(arrayLi.length == 0 && arrayLiInd == 0)
		{
			var searchVal = $("#systemName").val().toUpperCase(); 
			var row = $('#tt li .tree-node');  
			var rowcolumn = $('#tt li .tree-node > .tree-title');  
			var i = 0, j = 0;
			var offsetC = 0
			row.removeClass('tree-node-selected');  
			rowcolumn.each(function (column) {  
				var matchVal = $(this).text(); 
				if(matchVal.indexOf(searchVal) != -1)
				{
					i++;
					var panel_top = parseInt($(this).parents(".panel").css("top"), 10);
					
					if(i <= 1)
					{
						$(this).parent().addClass('tree-node-selected'); 
						var top = $(".tree_con").scrollTop() + $(this).offset().top - 76 - panel_top;
						$(".tree_con").scrollTop(top);
						arrayLiInd = 1;
					}			
					arrayLi.push([matchVal,$(".tree_con").scrollTop() + $(this).offset().top - 76 - panel_top]);
					
				}
				}); 
			}else
			{
				var rowcolumn = $('#tt li .tree-node > .tree-title'); 
				var row = $('#tt li .tree-node');  
				row.removeClass('tree-node-selected');
				
				if(arrayLiInd <  arrayLi.length)
				{
					rowcolumn.each(function (column) {  
						var matchVal = $(this).text(); 
						if(matchVal == arrayLi[arrayLiInd][0])
						{
							$(this).parent().addClass('tree-node-selected'); 
							$(".tree_con").scrollTop(arrayLi[arrayLiInd][1]);
							arrayLiInd++;
							return false;
						}
					});
				}else
				{
					//arrayLi = [];
					arrayLiInd = 0;
					$(".tree_con").scrollTop(0);
					choose_tree();
				}
			}
	}
	
	var loading_point = {
			timer:null,
			len:3,
			count:0
		};
	function loading1()
	{
	 	if(loading_point.count < loading_point.len)
		{
			loading_point.count++;
			$("#progressbar_point1").text($("#progressbar_point1").text() + ".");
		}else
		{
			loading_point.count = 0;
			$("#progressbar_point1").text("");
		}	
	}
	
	function loading2()
	{
	 	if(loading_point.count < loading_point.len)
		{
			loading_point.count++;
			$("#progressbar_point2").text($("#progressbar_point2").text() + ".");
		}else
		{
			loading_point.count = 0;
			$("#progressbar_point2").text("");
		}	
	}
	
	function loading3()
	{
	 	if(loading_point.count < loading_point.len)
		{
			loading_point.count++;
			$("#progressbar_point3").text($("#progressbar_point3").text() + ".");
		}else
		{
			loading_point.count = 0;
			$("#progressbar_point3").text("");
		}	
	}
	
	/* 树 */
	
	
	//选择多个接口进行邮件提示
	//一次审核多个接口
	function onTipAudits(){
		var httpIds  = "";
		var ftpIds = "";
		var rows = $('#datagrid').datagrid('getChecked'); 
		if(rows.length == 0){
 			$.messager.alert('警告',"<p>请选中要发送接口注册邮件信息的记录!</p>","warning");
 			return ;
 		}
		for(var i = 0; i <　rows.length; i++){
			if(rows[i].type === '3'){
				//ftp接口
				if(rows[i].auditStatus === '未审核'){
					ftpIds += (ftpIds == ""?"":",") + rows[i].interfaceId;
				}
			}else{
				//http接口
				if(rows[i].auditStatus === '未审核'){
					httpIds += (httpIds == ""?"":",") + rows[i].interfaceId;
				}
			}
			
		}
		
		if(httpIds == "" && ftpIds == ""){
			$.messager.alert('警告',"<p>所选择的接口已经通过审核!</p>","warning");
 			return ;
		}
		var jsonData = {
				httpIds:httpIds,
				ftpIds:ftpIds,
		}
		
		$("#progressbar1, #progressbar_tips1").fadeIn();
		loading_point.timer = setInterval(loading1,200);
		
		$.ajax({
  			type: "get",
  			url: BASE_URL_HTTP_INTERFACE + '/batchSendIfRegisterEmail' + '?v=' + Math.random(),
  			dataType:'json',
  			data: jsonData,
  			contentType:"application/json",
  			success: function(result) {
  				$("#progressbar1, #progressbar_tips1").fadeOut();
				clearInterval(loading_point.timer);
				
				$.messager.alert('提示','<p>注册接口发送的邮件提醒审核成功!</p>','info',function(){
						$('#datagrid').datagrid('reload');
					});
  				
  			},
  			error: function() {
  				$("#progressbar1, #progressbar_tips1").fadeOut();
				clearInterval(loading_point.timer);
  				$.messager.alert('错误','<p>服务异常，审核失败，请稍后重试或联系管理员!</p>', 'error');
  			}
  		});
	}
	
	